<%--
  Created by IntelliJ IDEA.
  User: Wang Ziming
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>登录</title>

    <%--<script type="text/javascript" src="../../js/jquery.min.js"/>--%>
    <script type="text/javascript">
        //初步判断邮箱、密码是否合法
        function verify(){
            try {
                var email = document.getElementById("email").value;
                var password = document.getElementById("password").value;
                if (isEmpty(email)) {
                    throw "邮箱为空";
                }
                if (isEmpty(password)) {
                    throw "密码为空";
                }
            } catch (e) {
                //以最朴素的方式打印出错误处理结果
                alert(e);
            }
        }

        /**
         * 判断字符串是否为空：账户 / 密码
         * @param str
         * @returns {boolean}
         */
        function isEmpty(str) {
            if (str == null || str.trim() == "") {
                return true;
            }
            return false;
        }
    </script>
</head>
<body>
<%--/user/login与user/login不同，/user/login更有准确性，不重复。--%>
<form action="/user/login" method="post" id="loginForm">
    邮箱：<input type="text" name="email" id="email" value="${messageModel.object.email}"><br>
    密码：<input type="text" name="password" id="password" value="${messageModel.object.password}"><br>
    <span id="msg" style="font-size: 12px;color: red;">${messageModel.msg}</span><br>
    <input type="submit" value="登录" onclick="verify()">
    <%--jquery的方式发现有问题--%>
    <%--<button type="button" id="loginBtn">登录</button>--%>
</form>
</body>
</html>